import {BasePage, BaseColumn} from "../../../../../ts/type";
import {replace, stampToDatetimeText} from "../../../../../ts/util";
import {h} from "vue";

export let entityColumnRelationColumnInit = (page: BasePage) => {
    page.columns.push(replace(new BaseColumn('index', ''), {
        width: 60
    }))
    page.columns.push(replace(new BaseColumn('id', 'ID'), {
        sorter: 'default',
        defaultSortOrder: 'descend',
        width: 80
    }))
// field column auto
// #bind.field.sourceFieldCode#
    page.columns.push(new BaseColumn('sourceFieldCode', '依赖字段'))
// $bind.field.sourceFieldCode$

// #bind.field.targetFieldCode#
    page.columns.push(new BaseColumn('targetFieldCode', '被依赖属性'))
// $bind.field.targetFieldCode$

// #bind.field.sourceTableCode#
    page.columns.push(new BaseColumn('sourceTableCode', '依赖表名'))
// $bind.field.sourceTableCode$

// #bind.field.targetTableCode#
    page.columns.push(new BaseColumn('targetTableCode', '被依赖表名'))
// $bind.field.targetTableCode$

// field label auto
// #bind.field.sourceTableCode#
    page.columns.push(new BaseColumn('sourceTableCodeLabel', '表名'))
// $bind.field.sourceTableCode$

// #bind.field.targetTableCode#
    page.columns.push(new BaseColumn('targetTableCodeLabel', '表名'))
// $bind.field.targetTableCode$

// #bind.field.sourceFieldCode#
    page.columns.push(new BaseColumn('sourceFieldCodeLabel', '属性名称'))
// $bind.field.sourceFieldCode$

// #bind.field.targetFieldCode#
    page.columns.push(new BaseColumn('targetFieldCodeLabel', '属性名称'))
// $bind.field.targetFieldCode$

    page.columns.push(new BaseColumn('createBy', '创建人'))
    page.columns.push(new BaseColumn('updateBy', '修改人'))
    page.columns.push(replace(new BaseColumn('createTime', '创建时间'), {
        render: (row: any) => {
            return h('span', stampToDatetimeText(row.createTime))
        }
    }))
    page.columns.push(replace(new BaseColumn('updateTime', '修改时间'), {
        render: (row: any) => {
            return h('span', stampToDatetimeText(row.updateTime))
        }
    }))
}